package com.ruoyi.find.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.find.domain.SecondHandHouse;
import com.ruoyi.find.service.ISecondHandHouseService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * vr房源Controller
 * 
 * @author yang
 * @date 2025-09-24
 */
@Tag(name = "VR房源管理", description = "VR房源相关接口")
@RestController
@RequestMapping("/house")
public class SecondHandHouseController extends BaseController
{
    @Autowired
    private ISecondHandHouseService secondHandHouseService;

    /**
     * 查询vr房源列表
     */
    @Operation(summary = "查询VR房源列表", description = "获取所有VR房源的分页列表")
    @RequiresPermissions("find:house:list")
    @GetMapping("/list")
    public TableDataInfo list(SecondHandHouse secondHandHouse)
    {
        startPage();
        List<SecondHandHouse> list = secondHandHouseService.selectSecondHandHouseList(secondHandHouse);
        return getDataTable(list);
    }

    /**
     * 导出vr房源列表
     */
    @Operation(summary = "导出VR房源列表", description = "将VR房源列表导出为Excel文件")
    @RequiresPermissions("find:house:export")
    @Log(title = "vr房源", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SecondHandHouse secondHandHouse)
    {
        List<SecondHandHouse> list = secondHandHouseService.selectSecondHandHouseList(secondHandHouse);
        ExcelUtil<SecondHandHouse> util = new ExcelUtil<SecondHandHouse>(SecondHandHouse.class);
        util.exportExcel(response, list, "vr房源数据");
    }

    /**
     * 获取vr房源详细信息
     */
    @Operation(summary = "获取VR房源详细信息", description = "根据房源ID获取VR房源详细信息")
    @RequiresPermissions("find:house:query")
    @GetMapping(value = "/{houseId}")
    public AjaxResult getInfo(@PathVariable("houseId") Long houseId)
    {
        return success(secondHandHouseService.selectSecondHandHouseByHouseId(houseId));
    }

    /**
     * 新增vr房源
     */
    @Operation(summary = "新增VR房源", description = "创建新的VR房源信息")
    @RequiresPermissions("find:house:add")
    @Log(title = "vr房源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SecondHandHouse secondHandHouse)
    {
        return toAjax(secondHandHouseService.insertSecondHandHouse(secondHandHouse));
    }

    /**
     * 修改vr房源
     */
    @Operation(summary = "修改VR房源", description = "更新指定的VR房源信息")
    @RequiresPermissions("find:house:edit")
    @Log(title = "vr房源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SecondHandHouse secondHandHouse)
    {
        return toAjax(secondHandHouseService.updateSecondHandHouse(secondHandHouse));
    }

    /**
     * 删除vr房源
     */
    @Operation(summary = "删除VR房源", description = "批量删除指定的VR房源")
    @RequiresPermissions("find:house:remove")
    @Log(title = "vr房源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{houseIds}")
    public AjaxResult remove(@PathVariable Long[] houseIds)
    {
        return toAjax(secondHandHouseService.deleteSecondHandHouseByHouseIds(houseIds));
    }
}
